InsertText('This file is required to decode the DICOM header. It is available from: ftp://zippy.nimh.nih.gov/pub/nih-image/documents/dicom-dict.hqx. It must be located in the same folder as NIH Image or in the System folder.', true)
end;
InsertText('', true);
end;
end;
begin
vr :='--';
err := 0;
buflen := maxbuf + 1;
open_sw := false;
TestError(fsopen(fname, vNum, f), 'Open');
open_sw := true;
TestError(FSRead(f, buflen, @buf), 'Read');
TestError(fsclose(f), 'Close');
if name4ptr(longint(@buf) + id_offset)^ = 'DICM' then
FirstElement:=FirstDicomElement
else if name4ptr(longint(@buf))^ = 'DICM' then
FirstElement:=4
else
FirstElement:=0; {TestError(1, 'This is not a DICOM file.');}
OpenDicomTextWindow;
sliceSpacingStg := '1.0';
rescaleInterceptStg := '0.0';
rescaleSlopeStg := '1.0';
imgNumString := '';
height := -1;
width := -1;
offset := -1;
index := 0;
lastGroup := $8;
done := false;
scale := '0.0';
aspect := '1.0';
representation := 0;
bitsAllocated := 16;
seriesMin := 0;
seriesMax := 0;
units := '';
repeat
GetNextElement;
if (index < 0) or (index >= buflen) then
leave;
if (elementWord = 0) and (elementLength = 0) then
leave;
if IsElement($18, $88) then
sliceSpacingStg := GetString(index)
else if IsElement($20, $13) then
imgNumString := GetString(index)
else if IsElement($28, $10) then
height := GetInteger(index)
else if IsElement($28, $11) then
width := GetInteger(index)
else if IsElement($28, $30) then
scale := GetString(index)
else if IsElement($28, $34) then
aspect := GetString(index)
else if IsElement($28, $100) then
bitsAllocated := GetInteger(index)
else if IsElement($28, $103) then
representation := GetInteger(index)
else if IsElement($28, $108) then
seriesMin := GetInteger(index)
else if IsElement($28, $109) then
seriesMax := GetInteger(index)
else if IsElement($28, $1052) then
rescaleInterceptStg := GetString(index)
else if IsElement($28, $1053) then
rescaleSlopeStg := GetString(index)
else if IsElement($7FE0, $10) then begin
offset := index;
done := true;
end;
if CommandPeriod then
listAll := false;
until done;
if (width = -1) or (height = -1) or (offset = -1) then begin
InsertText('', true);
InsertText('Unable to decode DICOM header.', true);
GetDICOMParams := -1;
exit(GetDICOMParams)
end;
{Image dimension information}
ImportCustomWidth := width;
ImportCustomHeight := height;
ImportCustomOffset := offset;
ImportSwapBytes := true; {(representation = 1);}
{Intensity information}
if bitsAllocated = 8 then begin
ImportCustomDepth := EightBits;
if ImageNumber=1 then
InsertText('', true);
GetDICOMParams := err;
exit(GetDICOMParams);
end else
ImportCustomDepth := SixteenBitsSigned;
if not ((seriesMin = 0) and (seriesMax = 0)) then begin
ImportAutoScale:=false;
ImportMin:=seriesMin;
ImportMax:=seriesMax;
end else if (ImageNumber>1) and UseFixedScale then begin